package io.github.uicdb.flame_driven.common.block;

import io.github.noeppi_noeppi.libx.base.tile.BlockBE;
import io.github.noeppi_noeppi.libx.mod.ModX;
import io.github.uicdb.flame_driven.FlameDriven;
import io.github.uicdb.flame_driven.ModUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;

public class BlockLifeExtra extends BlockBE<BELifeExtra> {
    public BlockLifeExtra( Properties properties) {
        super(FlameDriven.getInstance(), BELifeExtra.class, properties);
    }
    @Override
    public void neighborChanged(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Block pBlock, @NotNull BlockPos pFromPos, boolean pIsMoving) {
        super.neighborChanged(pState, pLevel, pPos, pBlock, pFromPos, pIsMoving);
        if (pLevel.hasNeighborSignal(pPos)) {
            getBlockEntity(pLevel, pPos).setStart(true);
        }
    }
    @NotNull
    @Override
    public InteractionResult use(@NotNull BlockState pState, Level pLevel, @NotNull BlockPos pPos, @NotNull Player pPlayer, @NotNull InteractionHand pHand, @NotNull BlockHitResult pHit) {
        return ModUtil.takeOrInsertItem(pLevel,pPos,pPlayer,pHand,0,1);
    }
}
